package cn.fzhui.servlet;

import cn.fzhui.factory.ServiceFactory;
import cn.fzhui.service.StudentService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

public class DeleteStudentServlet extends AuthServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StudentService studentService = ServiceFactory.getStudentService();
        try {
            studentService.delete(Integer.parseInt(req.getParameter("id")));
        } catch (SQLException exception) {
            exception.printStackTrace();
        }
        resp.sendRedirect("index");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

}
